<!DOCTYPE html >
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0' />
    <meta name='format-detection' content='telephone=no,email=no,date=no,address=no'>
    <link rel='stylesheet' href='./css/Version.css'>
    <title></title>
    <style>
        html,
        body,
        #app,
        .Version_box {
            background: rgba(0, 0, 0, .3)
        }
    </style>
</head>

<body>
    <div id='app'>
        <div class="Version_box">
            <div class="Version_win animated zoom">
                <div class="Version_win_header">
                    <div class="Version_win_header_bg">
                        <img src="../../../image/308/Version_header.png" alt="">
                    </div>
                    <span>更新提示</span>
                    <div class="Version_win_header_huo">
                        <img src="../../../image/308/hjian.png" alt="">
                    </div>
                    <!-- <div class="Version_win_header_close" @click="closeF">
                        <img src="../../static/image/close.png" alt="">
                    </div> -->
                </div>
                <div class="Version_win_center">
                    <p>
                        检测到您的版本过低<br> 请升级更新
                    </p>
                </div>
                <div class="Version_win_bot">
                    <div class="Version_win_bot_btn" @click="getV">
                        立即更新
                    </div>
                </div>
                <div class="Version_win_progress animated">
                    <div class="progress-bar blue stripes">
                        <span style="width: 0%;"></span>
                        <div class="progress_box" v-html="num+'%'"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script src='../../vue.js'></script>
<script src='../../sea.js' data-main='../../main'></script>
<script type='text/javascript'>
    seajs.use(['jquery', 'api'], function($, $api) {
        var vm = new Vue({
            el: '#app',
            data: {
                num: 0,
                offon: true
            },
            mounted: function() {
                this.init()
            },
            methods: {
                init: function() {
                    // app.ready()
                    even()
                },
                // 点击更新
                getV: function() {
                    var that = this
                    $('.Version_win_progress').css('opacity',"1");
                    if (this.offon) {
                        this.offon = false
                        if (api.systemType == "android") {
                            api.download({
                                url: api.pageParam.android_URL,
                                report: true,
                                allowResume: true
                            }, function(ret, err) {
                                if (ret && 0 == ret.state) { /* 下载进度 */
                                    that.num = ret.percent
                                    $('.Version_win_progress').find('span').css('width', ret.percent +
                                        '%');
                                }
                                if (ret && 1 == ret.state) { /* 下载完成 */
                                    $api.setStorage('savePath', ret.savePath);
                                    api.installApp({
                                        appUri: ret.savePath
                                    });
                                }
                            });
                        } else {
                            api.installApp({
                                appUri: api.pageParam.iosURl
                            });
                        }
                    } else {
                        if (api.systemType == "android") {
                            api.installApp({
                                appUri: $api.getStorage('savePath')
                            });
                        } else {
                            api.installApp({
                                appUri: api.pageParam.iosURl
                            });
                        }
                    }
                },
                // 关闭弹窗
                closeF: function() {
                    api.closeFrame();
                }
            }
        })

        function even() {}
    })
    apiready = function() {}
</script>
